package com.example.kaogong.sys.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.kaogong.sys.pojo.CourseComment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.kaogong.sys.pojo.UserLike;
import com.example.kaogong.sys.pojo.vo.CourseCommentVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 课程讨论 Mapper 接口
 * </p>
 *
 * @author    
 * @since 2022-03-31
 */

@Mapper
public interface CourseCommentMapper extends BaseMapper<CourseComment> {

    /**
     * 分页获取课程评论
     * @param courseCommentVoPage
     * @param courseId
     * @param commentId
     * @return
     */
    Page<CourseCommentVo> getCourseComment(@Param("page") Page<CourseCommentVo> courseCommentVoPage, @Param("courseId") Integer courseId, @Param("commentId") Integer commentId);

    /**
     * 管理员屏蔽某条评论
     * @param commentId
     * @return
     */
    @Update({"update t_course_comment set content = '该评论已被屏蔽' where comment_id = #{commentId}"})
    int shieldComment(Integer commentId);

    /**
     * 新增用户点赞课程评论记录
     * @param userLike
     * @return
     */
    int insertUserCourseCommentLike(UserLike userLike);

    @Update({"update t_course_comment set `like` = `like` + 1\n" +
            "where comment_id = #{commentId}"})
    int likeComment(Integer commentId);
}
